class NamedAliasedData(object):
    def __init__(self, name, aliases=None):
        self.name = name
        self.aliases = aliases or []

    def add_alias(self, alias):
        lowered = alias.lower()
        known_aliases = [x.lower() for x in self.aliases]

        if lowered not in known_aliases and lowered != self.name.lower():
            self.aliases.append(alias)

    def determine_name(self, new_name):
        old_name = self.name

        if new_name.lower() != old_name.lower():
            self.name = new_name
            self.aliases.append(old_name)

            for name in self.aliases:
                if new_name.lower() == name.lower():
                    self.aliases.remove(name)

